<!doctype html>
<html lang="en-us" dir="ltr">
  <head>
  <meta charset="utf-8">
    
  
    <!-- JS2CAL -->
	<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jscal2/jscal2.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jscal2/border-radius.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/jscal2/gold/gold.css" />
    <script type="text/javascript" src="<?php echo base_url();?>js/jscal2/jscal2.js"></script>
    <script type="text/javascript" src="<?php echo base_url();?>js/jscal2/lang/th.js"></script>
  </head>

  <body>
	<form action="<?php echo site_url('truckacc/exportCSV');?>" method="post">
    <table>
      <tr>
        <td>
        
       
          <input size="30" id="f_date1" name="date" value="<?=$date;?>" /><button id="f_btn1">...</button>
        </td> 
      </tr>
      <tr>
      	<td>
          partnum:<input type="text" name="partnum" value="<?=$partnum;?>"/>
         </td>
	 </tr>
	  <tr>
      	<td>
          partname:<input type="text" name="partname" value="<?=$partname;?>"/>
         </td>
	 </tr>
	  <tr>
      	<td>
          depcode:<input type="text" name="depcode" value="<?=$depcode;?>"/>
         </td>
	 </tr>
	 <tr>
	 	<td>
	 	<input type="submit" name="oksubmit" value="OK" />
	 	<input type="submit" name="gensubmit" value="export CSV" />
	 	</td>
	 </tr>
    </table>
     </form>
    <script type="text/javascript">//<![CDATA[

      var SELECTED_RANGE = null;
      function getSelectionHandler() {
              var startDate = null;
              var ignoreEvent = false;
              return function(cal) {
                      var selectionObject = cal.selection;

                      // avoid recursion, since selectRange triggers onSelect
                      if (ignoreEvent)
                              return;

                      var selectedDate = selectionObject.get();
                      if (startDate == null) {
                              startDate = selectedDate;
                              SELECTED_RANGE = null;
                              document.getElementById("info").innerHTML = "Click to select end date";

                              // comment out the following two lines and the ones marked (*) in the else branch
                              // if you wish to allow selection of an older date (will still select range)
                              cal.args.min = Calendar.intToDate(selectedDate);
                              cal.refresh();
                      } else {
                              ignoreEvent = true;
                              selectionObject.selectRange(startDate, selectedDate);
                              ignoreEvent = false;
                              SELECTED_RANGE = selectionObject.sel[0];

                              // alert(SELECTED_RANGE.toSource());
                              //
                              // here SELECTED_RANGE contains two integer numbers: start date and end date.
                              // you can get JS Date objects from them using Calendar.intToDate(number)

                              startDate = null;
                              document.getElementById("info").innerHTML = selectionObject.print("%Y-%m-%d") +
                                      "<br />Click again to select new start date";

                              // (*)
                              cal.args.min = null;
                              cal.refresh();
         this.hide();
                      }
              };
      };

      Calendar.setup({
              //cont          : "cont",
     inputField : "f_date1",
     trigger    : "f_btn1",
     max: <?php echo date('Ymd');?>,
              fdow          : 1,
              selectionType : Calendar.SEL_SINGLE,
              onSelect      : getSelectionHandler()
      });

    //]]></script>

	<table>
    	<thead>
    		<tr>
    		<?php 
    			foreach ($headertable as $head):
    		?>
    			<th><?php echo $head;?></th>
    		<?php 	
    			endforeach;
    		?>
    		</tr>
    	</thead>
    	<tbody>
    		<?php 
    			foreach ($resultarray as $row):
    		?>
    				<tr>
    					<?php 
    						foreach ($row as $eadata):
    					?>
    						<td><?php echo $eadata;?></td>
			    		<?php 	
			    			endforeach;
			    		?>
    				</tr>
    		<?php 	
    			endforeach;
    		?>
    	
    	</tbody>
 	</table>	

  </body>
</html>